home *** CD-ROM | disk | FTP | other *** search
/ Biodiversity of Illinois 2: Woodland Habitats / Biodiversity of Illinois 2 - Woodland Habitats.iso / mac / casts / PDFxtraBehaviors.cst / 00015_Script_PDF_ScrollTo < prev    next >
Text File  |  2006-07-11  |  4KB  |  120 lines

  1. -- Scroll To
  2.  
  3. Property pEvent, pSprite, pZoom, pScale, pX, pY, pAlertFlag
  4.  
  5. on doScrollTo me
  6.   case pZoom of:
  7.     "Fit Width": set m = #fitWidth
  8.     "Actual Size": set m = #actualSize
  9.     "Fit Page": set m = #fitPage
  10.     "Fit Visible": set m = #fitVisible
  11.       --    "None (Acrobat/Win only)": set m = #none
  12.     otherwise: 
  13.       if (pScale<8) or (pScale>1600) then
  14.         alert "Invalid zoom value"
  15.         exit
  16.       else
  17.         set m = #useScale
  18.       end if
  19.   end case
  20.   
  21.   set err = PDF_ScrollTo(sprite pSprite, m, pScale, pX, pY)
  22.   if PDF_status(sprite pSprite) then alert "PDF Behavior Error"&RETURN&PDF_error(sprite pSprite)
  23. end doScrollTo
  24.  
  25. on mouseUp me
  26.   if (pEvent = #mouseUp) then doScrollTo(me)
  27. end mouseUp
  28.  
  29. on mouseDown me
  30.   if (pEvent = #mouseDown) then doScrollTo(me)
  31. end mouseDown
  32.  
  33. on prepareFrame me
  34.   if (pEvent = #prepareFrame) then doScrollTo(me)
  35. end prepareFrame
  36.  
  37. -- standard behavior stuff --
  38. on getPropertyDescriptionList me
  39.   set defaultValues = GetDefaultValues (me)
  40.   
  41.   set pdfSpriteList = getProp (defaultValues, #spriteList)
  42.   set defSprite     = getProp (defaultValues, #defaultSprite)
  43.   if (defSprite=0) then 
  44.     if the ticks - pAlertFlag > 10 then
  45.       alert "Please create a sprite of type PDF first."
  46.     end if
  47.     set pAlertFlag = the ticks -- The ticks when the user clicked "OK"
  48.     
  49.     exit
  50.   end if
  51.   set p_list = [:]
  52.   addprop p_list, #pEvent, [ #comment: "Event", #format:#symbol, #range:[#mouseUp, #mouseDown, #prepareFrame], #default:#mouseUp]
  53.   addprop p_list, #pSprite, [ #comment: "PDF Sprite is in channel:", #format:#symbol, #range:pdfSpriteList, #default:defSprite]
  54.   addprop p_list, #pZoom, [ #comment: "Zoom to:", #format:#symbol, #range:["Fit Width", "Actual Size", "Fit Page", "Fit Visible", "Other (specify below)"], #default:"Fit Width"]
  55.   addprop p_list, #pScale, [ #comment: "Other (8..1600):", #format:#integer, #default:""]
  56.   addprop p_list, #pX, [ #comment: "Scroll H:", #format:#integer, #default:0]
  57.   addprop p_list, #pY, [ #comment: "Scroll V:", #format:#integer, #default:0]
  58.   
  59.   return p_list
  60. end
  61.  
  62. on getBehaviorDescription
  63.   tmp = "Scroll PDF document to the specified Horizontal/Vertical pixel position within the sprite."  &RETURN& "Available for Windows Only."
  64.   tmp = tmp &RETURN&RETURN& "--- PARAMETERS ---"
  65.   tmp = tmp &RETURN& " - Event: mouseUp, mouseDown, or prepareFrame"
  66.   tmp = tmp &RETURN& " - Sprite is in channel: which channel contains the PDF Sprite"
  67.   tmp = tmp & RETURN& " - Zoom to: FitWidth, Actual Size, Fit Page, Fit Visible, Other."
  68.   tmp = tmp & RETURN& " - Other zoom (8..1600): A number representing the percentage to scale the document."
  69.   tmp = tmp & RETURN& " - Scroll H: Set the horizontal scroll position to the number of pixels specified."
  70.   tmp = tmp & RETURN& " - Scroll V: Set the vertical scroll position to the number of pixels specified."
  71.   
  72.   tmp = tmp &RETURN&RETURN& "Free to use and abuse. (c)1999 - 2005, Integration New Media, Inc."  &RETURN& "Thanks to James Newton for his suggestions"
  73.   return tmp
  74. end
  75.  
  76. on getBehaviorTooltip
  77.   return "Scroll PDF document to the specified Horizontal/Vertical" & RETURN& "pixel position within the sprite." &RETURN& "Available for Windows Only."
  78. end
  79.  
  80. -- utils --
  81. on GetDefaultValues me
  82.   if the currentSpriteNum then
  83.     set spriteList = GetSpriteList (me #PDF)
  84.     if count (spriteList) then
  85.       set defaultSprite = getAt (spriteList, 1)
  86.     else
  87.       set defaultSprite = 0
  88.     end if
  89.     
  90.     return [#spriteList: spriteList, #defaultSprite: defaultSprite]
  91.     
  92.   else -- the currentSpriteNum = 0
  93.     -- Director is merely recompiling this script: return dummy values
  94.     return [#spriteList: [1], #defaultSprite: 1]
  95.   end if
  96. end 
  97.  
  98.  
  99. on GetSpriteList me, memberType
  100.   -- return list of sprites of type memberType in current frame
  101.   global version
  102.   if (char 1 of version = 6) then
  103.     set maxSprite = 120
  104.   else
  105.     set maxSprite = the lastChannel
  106.   end if
  107.   
  108.   set aList=[]
  109.   
  110.   repeat with i = 1 to maxSprite
  111.     set spriteMember = the member of sprite i
  112.     -- if (string(m) contains "member 0") then next repeat -- unnecessary
  113.     if (the type of spriteMember = memberType) then -- (JN) Line break
  114.       append (aList, i)
  115.     end if
  116.   end repeat
  117.   
  118.   return aList
  119. end GetSpriteList
  120.